Skip to content

Wait for a header or an element value before a run starts - #61

Merged
Mpdreamz merged 1 commit into
mainfrom
preconditions
Nov 17, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
preconditions

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

Why

A post-deploy run against a live site can start before the deploy shows: the old build still answers, or the cache has not cleared. Journeys then fail one by one, or a stalled navigation looks like a regression. Waiting for the site to show the expected build first turns that into one clear failure, and it also flags a deploy that went through but did not land.

What

JourneyPreconditions.WaitAsync(browser, precondition, options) opens a page until a response header, or an element's text or attribute, shows a value (exact, contains or regex).

  • Timeout (default 10 s) bounds the wait and Interval (500 ms) spaces the looks.
  • Retries (default 2) counts looks that fail, such as a page that did not load or a dropped connection. A look that works and shows another value is not an error, so the wait goes on until Timeout.
  • Each look is a new context, so nothing is cached. The run's allow list, user agent, headers and read-only rule apply.
  • Page.Response gives the status and headers of the response that served the current document, from the Network events pages already collect.

The result says what was expected and what was last seen. DECISIONS.md and the network docs describe it, including that a value shared by two deploys passes at once.

Verification

Full suite passes (528). Nine new live tests: header and element values that change late, text, regex and contains, never arriving, missing header and element, retries recovering and giving up, a host outside the allow list, bad input. I broke the retry limit and the contains match and each made the matching tests fail; restored.

🤖 Generated with Claude Code

JourneyPreconditions.WaitAsync opens a page in a fresh context until a response
header, or an element's text or attribute, shows a value (exact, contains or
regex), within a timeout, looking every interval, and giving up when looks that
fail exceed the retries. The run's allow list, user agent, headers and read-only
rule apply. Page.Response exposes the status and headers of the main document.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Mpdreamz Mpdreamz added the feature A new capability (minor bump) label Nov 17, 2026
@Mpdreamz
Mpdreamz merged commit 115059e into main Nov 17, 2026
15 checks passed
@Mpdreamz
Mpdreamz deleted the preconditions branch November 17, 2026 10:21
Mpdreamz added a commit that referenced this pull request Nov 17, 2026
Main CI failed on ubuntu after #61:
`LooksThatFailAreRetriedAndGiveUpAfterTheRetries` hung the first looks
for 3 s and relied on a 400 ms navigation timeout. A slow runner
exceeded that for the looks that should have worked, so all three looks
failed.

The test server now starts late, or never. Until it starts, the port
refuses connections, so a look fails at once on any machine. The retry
and give-up checks are the same; the give-up case also asserts the
refused-connection error.

I ran the precondition tests three times locally, all green.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A new capability (minor bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant